/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package connectDB;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class ConnectDB {
    private Connection conn = null;
    private String user = "sa";
    private String pass = "alo1234";
    private String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    private String url = "jdbc:sqlserver://localhost:1433;databaseName=prjSem4";

    public Connection getConnect(){
        try {
            Class.forName(driver);
            conn = DriverManager.getConnection(url, user, pass);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(ConnectDB.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(ConnectDB.class.getName()).log(Level.SEVERE, null, ex);
        }
        return conn;
    }

    public static void main(String[] args) {
            ConnectDB obj = new ConnectDB();
            //System.out.print(obj.getConnect());
            if(obj.getConnect()!=null)
            {
                System.out.println("OK");
            }
            else
            {
                System.out.println("Failed");
            }
    }

}
